package com.jianbing.north.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jianbing.common.annotation.Log;
import com.jianbing.common.core.controller.BaseController;
import com.jianbing.common.core.domain.AjaxResult;
import com.jianbing.common.enums.BusinessType;
import com.jianbing.north.domain.NorthQuesOption;
import com.jianbing.north.service.INorthQuesOptionService;
import com.jianbing.common.utils.poi.ExcelUtil;
import com.jianbing.common.core.page.TableDataInfo;

/**
 * 题目选项Controller
 * 
 * @author ruoyi
 * @date 2024-06-20
 */
@RestController
@RequestMapping("/shasha/option")
public class NorthQuesOptionController extends BaseController
{
    @Autowired
    private INorthQuesOptionService northQuesOptionService;

    /**
     * 查询题目选项列表
     */
    // @PreAuthorize("@ss.hasPermi('shasha:option:list')")
    @GetMapping("/list")
    public TableDataInfo list(NorthQuesOption northQuesOption)
    {
        startPage();
        List<NorthQuesOption> list = northQuesOptionService.selectNorthQuesOptionList(northQuesOption);
        return getDataTable(list);
    }

    /**
     * 导出题目选项列表
     */
    // @PreAuthorize("@ss.hasPermi('shasha:option:export')")
    @Log(title = "题目选项", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NorthQuesOption northQuesOption)
    {
        List<NorthQuesOption> list = northQuesOptionService.selectNorthQuesOptionList(northQuesOption);
        ExcelUtil<NorthQuesOption> util = new ExcelUtil<NorthQuesOption>(NorthQuesOption.class);
        util.exportExcel(response, list, "题目选项数据");
    }

    /**
     * 获取题目选项详细信息
     */
    //  @PreAuthorize("@ss.hasPermi('shasha:option:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(northQuesOptionService.selectNorthQuesOptionById(id));
    }

    /**
     * 新增题目选项
     */
    //  @PreAuthorize("@ss.hasPermi('shasha:option:add')")
    @Log(title = "题目选项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NorthQuesOption northQuesOption)
    {
        return toAjax(northQuesOptionService.insertNorthQuesOption(northQuesOption));
    }

    /**
     * 修改题目选项
     */
    //   @PreAuthorize("@ss.hasPermi('shasha:option:edit')")
    @Log(title = "题目选项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NorthQuesOption northQuesOption)
    {
        return toAjax(northQuesOptionService.updateNorthQuesOption(northQuesOption));
    }

    /**
     * 删除题目选项
     */
    // @PreAuthorize("@ss.hasPermi('shasha:option:remove')")
    @Log(title = "题目选项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(northQuesOptionService.deleteNorthQuesOptionByIds(ids));
    }
}
